<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>

<script type="text/javascript">
	 	dojo.require("dijit.Editor");
		dojo.require("dijit.form.ValidationTextBox");
		dojo.require("dijit.form.DateTextBox");
		dojo.require("dojox.validate.regexp");
		dojo.require("dojo.parser");
</script>

<?php 	
		echo html::Stylesheet(
			array
			(
				'media/css/song_block.css',
			),
			array
			(
				'screen',
			)
		);	
?>

<script type="text/javascript">
		$(document).ready(function() {
			$("input[name='btnCancle']").click(function() {
				var uri = ISS.lang.getBasePath()+'index.php/admin/song';
				window.location = uri;
			});
		}); 
</script>

<div id="songContainer">
	<?php print form::open_multipart('admin/song/save');?>
	
	<div id="songBlock">
		<div id="songBlockTop">
			<h3><?php echo ($mode=='add') ? 'เพิ่มเพลง' : 'แก้ไขเพลง'; ?></h3>
				<?php 
		          	$array = array('mode' => $mode);
					print form::hidden($array);
					if ($mode=='edit') {
		          		$array = array('id' => $form['id']);
						print form::hidden($array);
					}
				?>
			<p><?php echo (empty($status) ? 'กรุณาระบุข้อมูลให้ครบถ้วน' : html::specialchars($status)); ?></p>
		</div>
        <div id="songBlockBody">
        	<table>
            	<tr>
            		<td>ชื่อ:</td>
                    <td>
                        <input type="text" name="txtTitle" value="<?php echo html::specialchars($form['title']); ?>" 
                                    dojoType="dijit.form.ValidationTextBox"
                                    trim="true"
                                    required="true"
                                    invalidMessage="กรุณาระบุชื่อเพลง" />
                         <div id='errTitle' class='albumBlockError'>
									<?php echo (empty ($errors['txtTitle'])) ? '' : $errors['txtTitle']; ?>
						 </div>
                    </td>
            	</tr>
            	<tr>
            		<td>ศิลปิน:</td>
            		<td>
            			<select style="width:150px" id="cboArtist" name="cboArtist">
            				<option value="0"></option>
            				<?php foreach ($artists as $artist):?>
            				<option value="<?php echo $artist['id']?>"><?php echo htmlspecialchars($artist['name'])?></option>
            				<?php endforeach ?>
            			</select>
            		</td>
            	</tr>
                <tr>
                	<td>
                    	แนวเพลง:
                    </td>
                    <td>
                    	<select style="width:150px"	id="cboGene" name="cboGene">
							<option value="0"></option>
							<?php foreach ($genes as $gene): ?>
							<option value="<?php echo $gene['id']; ?>"><?php echo html::specialchars($gene['name']); ?></option>
						    <?php endforeach ?>						    
						</select>
                    </td>
                </tr>
                <tr>
                	<td>
                    	อัลบัม:
                    </td>
                    <td>
                    	<select style="width:150px"	id="cboGene" name="cboAlbum">
							<option value="0"></option>
							<?php foreach ($albums as $album): ?>
							<option value="<?php echo $album['id']; ?>"><?php echo html::specialchars($album['title']); ?></option>
						    <?php endforeach ?>						    
						</select>
                    </td>
                </tr>
                <tr>
                	<td>
                    	ลำดับเพลง:
                    </td>
                    <td>
                    	<input type="text" name="txtTreckNo" value="<?php echo html::specialchars($form['track_no']); ?>" 
                                    dojoType="dijit.form.ValidationTextBox"
                                    trim="true"
                                    required="true"
                                    invalidMessage="กรุณาระบุลำดับเพลง" />
                    </td>
                </tr>
                <tr>
                	<td>
                    	ความยาวเพลง(นาที:วินาที)
                    </td>
                    <td>
                    	<input type="text" name="txtDuration" value="" 
                                    dojoType="dijit.form.ValidationTextBox"
                                    trim="true"
                                    invalidMessage="กรุณาระบุความยาวเพลง" />
                    </td>
                </tr>
                <tr>
                	<td>
                		ไฟล์เพลงตัวอย่าง:
                	</td>
                	<td>
	                        <?php
								if (!empty($form['sample_file'])) {
									echo '<img id=sample_file  alt="'. html::specialchars($form['title']) .'" src="'. url::base() . html::specialchars($form['sample_file']) .'" />';
									echo '<br/>';
								} 
								$attributes = array('name' => 'txtSampleFile');
								echo form::upload($attributes, '');	
							?>
							<div id='errAlbumsPicture' class='albumBlockError'>
								<?php echo (empty ($errors['txtCoverPicture'])) ? '' : $errors['txtCoverPicture']; ?>
							</div>
                	</td>
                </tr>
                <tr>
                	<td>
                		ไฟล์เพลงคุณภาพต่ำ:
                	</td>
                	<td>
                		<input type="file" name="txtLowBit" value="<?php echo html::specialchars($form['low_bit_rate_file']); ?>" />
                	</td>
                </tr>
                <tr>
                	<td>
                		ไฟล์เพลงคุณภาพสูง:
                	</td>
                	<td>
                		<input type="file" name="txtHingBit" value="<?php echo html::specialchars($form['high_bit_rate_file']); ?>" />
                	</td>
                </tr>
            </table>
        </div>
	</div>
	<div id="songBlockBot">
		<?php print form::submit('btnSave', 'บันทึก'); ?>
		<input type="button" id="btnCancle" name="btnCancle" value="ยกเลิก" />
	</div>
</div>
